import 'package:flutter/material.dart';

class ButtonData extends StatefulWidget {
  final String title;
  final Function onTapHanele;

  const ButtonData({Key key, this.title, this.onTapHanele}) : super(key: key);

  @override
  State<ButtonData> createState() => _ButtonDataState();
}

class _ButtonDataState extends State<ButtonData> {
  @override
  Widget build(BuildContext context) {
    final List<ButtonData> ButtonDataItem = [
      ButtonData(
        title: '看房记录',
        onTapHanele: () {
          Navigator.pushNamed(context, 'login');
        },
      ),
      ButtonData(
        title: '我的订单',
        onTapHanele: () {},
      ),
      ButtonData(
        title: '我的收藏',
        onTapHanele: () {},
      ),
      ButtonData(
        title: '身份认证',
        onTapHanele: () {},
      ),
      ButtonData(
        title: '联系我们',
        onTapHanele: () {},
      ),
      ButtonData(
        title: '电子合同',
        onTapHanele: () {},
      ),
      ButtonData(
        title: '房屋管理',
        onTapHanele: () {},
      ),
    ];
    return Wrap(
      spacing: 1,
      runSpacing: 1,
      children: ButtonDataItem.map((item) => Container(
            alignment: Alignment.center,
            height: 50,
            decoration: BoxDecoration(color: Colors.red),
            width: MediaQuery.of(context).size.width * 0.33,
            child: GestureDetector(
              onTap: item.onTapHanele,
              child: Text(item.title),
            ),
          )).toList(),
    );
  }
}
